// 参考写法
import { ref } from 'vue'
import { defineStore } from 'pinia'
import { getPublicAppI18n } from '@/api/qygly'
import { useUserStore } from '@/stores/user.js'
const userStore = useUserStore()
const langId = userStore.loginInfo?.currentLangId
export const useI18nStore = defineStore(
  'i18n',
  () => {
    const appI18n = ref({})
    const getAppI18n = () => {
      return new Promise((resolve, reject) => {
        getPublicAppI18n({ langId })
          .then((data) => {
            appI18n.value = data
            resolve()
          })
          .catch((err) => {
            reject(err)
          })
      })
    }

    return { appI18n, getAppI18n }
  },
  {
    persist: {
      key: 'qyglyAppI18nStore',
    },
  },
)
